<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>华美医药-后台</title>
  <link rel="stylesheet" href="../res/layui/css/layui.css">
  <script type="text/javascript" src="../res/js/jquery-3.4.1.min.js"></script>
</head>
<body class="layui-layout-body">
<form action="">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">华美医药 - 后台</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item"><a href="">控制台</a></li>
      <li class="layui-nav-item"><a href="">商品管理</a></li>
      <li class="layui-nav-item"><a href="">用户</a></li>
      <li class="layui-nav-item">
        <a href="javascript:;">其它系统</a>
        <dl class="layui-nav-child">
          <dd><a href="">邮件管理</a></dd>
          <dd><a href="">消息管理</a></dd>
          <dd><a href="">授权管理</a></dd>
        </dl>
      </li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;" id="img">
          
        </a>
        <dl class="layui-nav-child">
          <dd><a href="">基本资料</a></dd>
          <dd><a href="">安全设置</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="index/index.html">退了</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll" id="ste">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test" id="shou">
        <!-- <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">采购管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">采购材料管理</a></dd>
            <dd><a href="javascript:;">采购药品管理</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
        	<a class="" href="javascript:;">质检管理</a>
        	<dl class="layui-nav-child">
        		<dd><a href="javascript:;">药品质检入库</a></dd>
        	</dl>
        </li>
        <li class="layui-nav-item">
        	<a class="" href="javascript:;">销售管理</a>
        	<dl class="layui-nav-child">
        		<dd><a href="javascript:;">零售管理</a></dd>
        		<dd><a href="javascript:;">销售订单管理</a></dd>
        		<dd><a href="javascript:;">批发管理</a></dd>
        	</dl>
        </li>
        <li class="layui-nav-item">
        	<a class="" href="javascript:;">财务审核管理</a>
        	<dl class="layui-nav-child">
        		<dd><a href="javascript:;">采购审核</a></dd>
        		<dd><a href="javascript:;">销售审核</a></dd>
        		<dd><a href="javascript:;">材料采购审核</a></dd>
        		<dd><a href="javascript:;">批发审核</a></dd>
        	</dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">权限管理</a>
          <dl class="layui-nav-child">
            <dd><a id="1" class="tab" title="module.html" href="javascript:module.html;">模块管理</a></dd>
            <dd><a id="2" class="tab" title="User.html" href="javascript:user.html;">用户管理</a></dd>
            <dd><a id="3" class="tab" title="Role.html" href="javascript:role.html;">角色模块</a></dd>
          </dl>
        </li>
       <li class="layui-nav-item">
          <a href="javascript:;">药品管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">药品类型管理</a></dd>
            <dd><a href="javascript:;">药品管理</a></dd>
            <dd><a href="javascript:;">药材管理</a></dd>
            <dd><a href="javascript:;">材料类型管理</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">退货管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">采购退货</a></dd>
            <dd><a href="javascript:;">零售退货</a></dd>
            <dd><a href="javascript:;">批发退货</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">库存管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">药品库存管理</a></dd>
            <dd><a href="javascript:;">材料库存管理</a></dd>
            <dd><a href="javascript:;">药材管理</a></dd>
            <dd><a href="javascript:;">材料类型管理</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">审核</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">分公司采购退货</a></dd>
            <dd><a href="javascript:;">总店总经理审核</a></dd>
          </dl>
        </li> -->
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <div class="layui-body">
  	<div id="top-tab" class="layui-tab layui-tab-brief" lay-filter="demo" lay-allowclose="true">
	  <ul class="layui-tab-title">
	    <li class="layui-this" id="noclose">首页</li>
	  </ul>
	  	<div class="layui-tab-content" style="height: 150px;">
		    <div class="layui-tab-item layui-show" align="center">
		   	<font color="red" style="font-size:100px" >首页</font><br>
		   	<!--  <img alt="" style="width:300px;height:300px"src="../upload/ohuo.jpg"> -->
		   
		    </div>
	 </div>
  	
	  </div>
	</div>
  </div>
</div>
</form>
<script src="../res/layui/layui.js"></script>
<script src="../res/js/tools.js"></script>
<script>
$.ajaxSetup({
	async:false
});
//JavaScript代码区域
layui.use(['element','form'], function(){
	var id = getQueryString("id");
  var element = layui.element;
  var form = layui.form ;
  var urls = '../User/findId.action';
  var datas = {id:id};
  $.post(urls,datas,function(obj){
	  $("#img").append('<img src="../'+obj.userImg+'" class="layui-nav-img">'+obj.userName+'');
  });
  var url = '../UserRole/findUserId.action';
	var data = {id:id};
	$.post(url,data,function(obj){
		var ser = ''
		$.each(obj,function(index,items){
			url = '../RoleModule/findRoleId.action';
			data = {id:items.role};
			$.post(url,data,function(objs){
				$.each(objs,function(indexxx,itemsss){
					var str = '';
					if(itemsss.modModuleId=="0"){
						var i = ser.indexOf(itemsss.moduleId);
						if(i==-1){
							i=1;
							str+='<li class="layui-nav-item ss"><a onclick=dian(this) href="javascript:;">'+itemsss.moduleName+'      ></a><dl class="layui-nav-child id='+itemsss.moduleId+'">';
						}
						ser+=itemsss.moduleId+",";
						$.each(objs,function(indexx,itemss){
							if(itemss.modModuleId==itemsss.moduleId){
								var j = ser.indexOf(itemss.moduleId);
								if(j==-1 && i==-1){
									$("#"+itemsss.moduleId).append('<dd><a id="'+itemss.moduleId+'" class="tab" title="'+itemss.moduleAddress+'" href="javascript:'+itemss.moduleAddress+';">'+itemss.moduleName+'</a></dd>');
								}else if(j==-1){
									str+='<dd><a id="'+itemss.moduleId+'" class="tab" title="'+itemss.moduleAddress+'" href="javascript:'+itemss.moduleAddress+';">'+itemss.moduleName+'</a></dd>';
								}
								ser+=itemss.moduleId+",";
							}
						})
						str+='</dl></li>';
						$("#shou").append(str);
						form.render();
					}
				})
				
			},'json')
		})
	},'json');
//一些事件监听
  element.on('tab(demo)', function(data){
    console.log(data);
  });
//新增或切换选项卡
	$(".tab").click(function(){
		var tabId =$(this).attr('id');//id=“2”
		var falg = true;
		var li = $("#top-tab li");
		$(li).each(function(i,element){
			if($(this).attr("lay-id")==tabId){
				falg = false;
				
			}
		});
		if(falg==false){
			element.tabChange('demo',tabId);//切换到指定的Tab项
		}else{
			element.tabAdd('demo', {
			  title: $(this).text()
			  ,content: '<iframe name="iframe" width="100%" style="min-height: 600px;" scrolling="yes" frameborder="0" noresize="noresize" src="'+$(this).attr("title")+'?userId='+id+'"></iframe>' //支持传入html
			  ,id:$(this).attr('id')
			  ,allowClose:true
			});
			element.tabChange('demo',tabId);//切换到指定的Tab项
		}
	});
	//关闭全部选项
	$("#close").dblclick(function(){
		var li = $("#top-tab li");
		$(li).each(function(i,ele){
			var layId = $(this).attr("lay-id");
			element.tabDelete('demo',layId);
		});
	});
});
function dian (obj){
$(obj).parent().find("dl").toggle();
}
</script>
</body>
</html>